package com.bl._03oneway;

import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.remoting.exception.RemotingException;

import java.nio.charset.StandardCharsets;
import java.util.List;

/**
 *  生产者
 */
public class Producer {

    public static void main(String[] args) throws MQClientException, MQBrokerException, RemotingException, InterruptedException {
        // 1 获取producer对象
        DefaultMQProducer producer = new DefaultMQProducer("oneway_product_group");
        // 2 设置nameserver地址链接
        producer.setNamesrvAddr("localhost:9876");
        // 3 启动Producer实例
        producer.start();
        // 4  创建消息，并指定Topic，Tag和消息体
        Message message = new Message("oneway", "hello", "学个基尔".getBytes(StandardCharsets.UTF_8));
        // 发送单例消息
        producer.sendOneway(message);
        // 5 关闭Producer实例。
        producer.shutdown();
    }

}
